<template>
    <div>
      <el-row :gutter="2">
        <el-col :span="8"><div>
          <hyl-search :formType="table.searchType" :formColumns="table.searchColumns" :formColumnsRule="table.searchColumnsRule" :customColumnsData="table.customSearchColumnsData" v-on:getFormData="getSearchFormData"></hyl-search>
          <hyl-table :tableData="table.tableData" :columns="table.columns" :specialColumns="table.specialColumns" v-on:tableSelection="tableSelection">
            <template slot="buttons">
              <el-button type="text" icon="el-icon-edit" @click="handleClick({},'edit')">编辑</el-button>
              <el-button type="text" icon="el-icon-circle-plus-outline" @click="handleClick({},'add')">添加</el-button>
              <el-button type="text" icon="el-icon-delete" @click="handleClick({},'delete')">删除</el-button>
              <el-button type="text" icon="el-icon-tickets" @click="handleClick({},'get')">获取</el-button>
            </template>
          </hyl-table>
          <!--<hyl-pagination :total="table.total" v-on:fetch="fetch" :page-sizes="[5,10,15]"/>-->
          <!-- 增加,删除 对话框  start -->
          <el-dialog title="添加"  :visible="table.addDialogVisible" width="40%" :show-close="false">
            <hyl-form :formColumns="table.addColumns" :formColumnsRule="table.addColumnsRule" :customColumnsData="table.customAddColumnsData" v-on:getFormData="getAddFormData" v-on:handleCancel="handleCancel"></hyl-form>
          </el-dialog>
          <el-dialog title="编辑" :visible.sync="table.editDialogVisible" width="40%">
            <hyl-form :formType="table.editType" :editData="table.editData" :formColumns="table.editColumns" :formColumnsRule="table.editColumnsRule" :customColumnsData="table.customEditColumnsData" v-on:getFormData="getEditFormData" v-on:handleCancel="handleCancel"></hyl-form>
          </el-dialog>
          <!-- 增加,删除 对话框  end -->
        </div></el-col>
        <el-col :span="8"><div>
          <hyl-search :formType="table2.searchType" :formColumns="table2.searchColumns" :formColumnsRule="table2.searchColumnsRule" :customColumnsData="table2.customSearchColumnsData" v-on:getFormData="getSearchFormData2"></hyl-search>
          <hyl-table :tableData="table2.tableData" :columns="table2.columns" :specialColumns="table2.specialColumns" v-on:tableSelection="tableSelection2">
            <template slot="buttons">
              <el-button type="text" icon="el-icon-edit" @click="handleClick2({},'edit')">编辑</el-button>
              <el-button type="text" icon="el-icon-circle-plus-outline" @click="handleClick2({},'add')">添加</el-button>
              <el-button type="text" icon="el-icon-delete" @click="handleClick2({},'delete')">删除</el-button>
              <el-button type="text" icon="el-icon-tickets" @click="handleClick2({},'get')">获取</el-button>
            </template>
          </hyl-table>
          <!--<hyl-pagination :total="table2.total" v-on:fetch="fetch" :page-sizes="[5,10,15]"/>-->
          <!-- 增加,删除 对话框  start -->
          <el-dialog title="添加"  :visible="table2.addDialogVisible" width="40%" :show-close="false">
            <hyl-form :formType="table2.addType" :formColumns="table2.addColumns" :formColumnsRule="table2.addColumnsRule" :customColumnsData="table2.customAddColumnsData" v-on:getFormData="getAddFormData2" v-on:handleCancel="handleCancel2"></hyl-form>
          </el-dialog>
          <el-dialog title="编辑" :visible.sync="table2.editDialogVisible" width="40%">
            <hyl-form :formType="table2.editType" :editData="table2.editData" :formColumns="table2.editColumns" :formColumnsRule="table2.editColumnsRule" :customColumnsData="table2.customEditColumnsData" v-on:getFormData="getEditFormData2" v-on:handleCancel="handleCancel2"></hyl-form>
          </el-dialog>
          <!-- 增加,删除 对话框  end -->
        </div></el-col>
        <el-col :span="8"><div>
          <hyl-search :formType="table3.searchType" :formColumns="table3.searchColumns" :formColumnsRule="table3.searchColumnsRule" :customColumnsData="table3.customSearchColumnsData" v-on:getFormData="getSearchFormData3"></hyl-search>
          <hyl-table :tableData="table3.tableData" :columns="table3.columns" :specialColumns="table3.specialColumns" v-on:tableSelection="tableSelection3">
            <template slot="buttons">
              <el-button type="text" icon="el-icon-edit" @click="handleClick({},'edit')">编辑</el-button>
              <el-button type="text" icon="el-icon-circle-plus-outline" @click="handleClick({},'add')">添加</el-button>
              <el-button type="text" icon="el-icon-delete" @click="handleClick({},'delete')">删除</el-button>
            </template>
          </hyl-table>
          <!--<hyl-pagination :total="table3.total" v-on:fetch="fetch" :page-sizes="[5,10,15]"/>-->
          <!-- 增加,删除 对话框  start -->
          <el-dialog title="添加"  :visible="table3.addDialogVisible" width="40%" :show-close="false">
            <hyl-form :formType="table3.addType" :formColumns="table3.addColumns" :formColumnsRule="table3.addColumnsRule" :customColumnsData="table3.customAddColumnsData" v-on:getFormData="getAddFormData3" v-on:handleCancel="handleCancel3"></hyl-form>
          </el-dialog>
          <el-dialog title="编辑" :visible.sync="table3.editDialogVisible" width="40%">
            <hyl-form :formType="table3.editType" :editData="table3.editData" :formColumns="table3.editColumns" :formColumnsRule="table3.editColumnsRule" :customColumnsData="table3.customEditColumnsData" v-on:getFormData="getEditFormData3" v-on:handleCancel="handleCancel3"></hyl-form>
          </el-dialog>
          <!-- 增加,删除 对话框  end -->
        </div></el-col>
      </el-row>
    </div>
</template>

<script>
import hylTable from '@/components/table'
import hylPagination from '@/components/pagination'
import hylForm from '@/components/form'
import hylSearch from '@/components/search'
import {fetch, del, post, put} from '@/utils/http'
export default {
  name: 'index',
  components: {
    hylTable,
    hylPagination,
    hylForm,
    hylSearch
  },
  data () {
    return {
      table: {
        tableData: [],
        total: 0,
        page: 1,
        limit: 5,
        specialColumns: [{
          type: 'selection',
          width: '55'
        }, {
          type: 'index',
          indexMethod: this.indexMethod
        }],
        columns: [],
        applicationName: '',
        controller: '',
        customAddColumnsData: {},
        addColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '菜单名称', dataType: 'varchar'}
        ],
        addColumnsRule: {},
        addData: {},
        customEditColumnsData: {},
        editColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '菜单名称', dataType: 'varchar'}
        ],
        editColumnsRule: {},
        editType: 'edit',
        editData: {},
        customSearchColumnsData: {},
        searchColumns: [],
        searchColumnsRule: {},
        cacheSearchData: {},
        searchType: 'search',
        multipleSelection: [],
        editDialogVisible: false,
        addDialogVisible: false,
        buttonsVisible: {
          add: {'security': '', visible: true},
          edit: {'security': 'back:user:update', visible: true},
          delete: {'security': 'back:user:delete', visible: true}
        }
      },
      table2: {
        tableData: [],
        total: 0,
        page: 1,
        limit: 5,
        specialColumns: [{
          type: 'selection',
          width: '55'
        }, {
          type: 'index',
          indexMethod: this.indexMethod
        }],
        columns: [],
        applicationName: '',
        controller: '',
        customAddColumnsData: {},
        addColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '菜单名称', dataType: 'varchar'}
        ],
        addColumnsRule: {},
        addData: {},
        customEditColumnsData: {},
        editColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '菜单名称', dataType: 'varchar'}
        ],
        editColumnsRule: {},
        editType: 'edit2',
        addType: 'add2',
        editData: {},
        customSearchColumnsData: {},
        searchColumns: [],
        searchColumnsRule: {},
        cacheSearchData: {},
        searchType: 'search2',
        multipleSelection: [],
        editDialogVisible: false,
        addDialogVisible: false,
        buttonsVisible: {
          add: {'security': '', visible: true},
          edit: {'security': 'back:user:update', visible: true},
          delete: {'security': 'back:user:delete', visible: true}
        }
      },
      table3: {
        tableData: [],
        total: 0,
        page: 1,
        limit: 5,
        specialColumns: [{
          type: 'selection',
          width: '55'
        }, {
          type: 'index',
          indexMethod: this.indexMethod
        }],
        columns: [],
        applicationName: '',
        controller: '',
        customAddColumnsData: {},
        addColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '权限名称', dataType: 'varchar'}
        ],
        addColumnsRule: {},
        addData: {},
        customEditColumnsData: {},
        editColumns: [
          {'prop': 'permission', 'label': '权限code', dataType: 'varchar'},
          {'prop': 'name', 'label': '权限名称', dataType: 'varchar'}
        ],
        editColumnsRule: {},
        editType: 'edit3',
        addType: 'add3',
        editData: {},
        customSearchColumnsData: {},
        searchColumns: [],
        searchColumnsRule: {},
        cacheSearchData: {},
        searchType: 'search3',
        multipleSelection: [],
        editDialogVisible: false,
        addDialogVisible: false,
        buttonsVisible: {
          add: {'security': '', visible: true},
          edit: {'security': 'back:user:update', visible: true},
          delete: {'security': 'back:user:delete', visible: true}
        }
      },
      shareData: {
        tableId: '',
        table2Id: ''
      }
    }
  },
  mounted: function () {
    this.getColumns()
    this.fetch()
    /// 页面权限控制
    this.table.buttonsVisible.add.visible = false
    this.table.buttonsVisible.edit.visible = false
    this.table.buttonsVisible.delete.visible = false
    this.table.resources.forEach((item) => {
      if (item === this.table.buttonsVisible.add.security) {
        this.table.buttonsVisible.add.visible = true
      }
      if (item === this.table.buttonsVisible.edit.security) {
        this.table.buttonsVisible.edit.visible = true
      }
      if (item === this.table.buttonsVisible.delete.security) {
        this.table.buttonsVisible.delete.visible = true
      }
    })
  },
  methods: {
    handleClick (row = {}, type = '') {
      switch (type) {
        case 'add':
          // 显示添加数据对话框
          this.table.addDialogVisible = true
          // 如查要对数据进行处理,在此进行,如:datetime类型
          /// 数据处理完后,赋值操作
          this.table.addData = row
          // alert('add')
          break
        case 'delete':
          // 一行或多行删除操作
          if (this.table.multipleSelection.length > 0) {
            // 此处生成写法是默认数据库表中字段id为唯一key值,name这一行记录名称(方便知道删除的是神马!))
            let ids = ''
            let names = ''
            this.table.multipleSelection.forEach((selection) => {
              ids = ids + selection.id + ','
              names = names + selection.name + ','
            })
            this.$confirm(names + '确定要删除, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.delete(this.table.applicationName + '/' + this.table.controller + '/deleteBatch', {params: {ids: ids.slice(0, ids.length - 1)}})
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          } else {
            /// 不符合条件
            this.$confirm('此操作需要至少选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('删除')
          break
        case 'edit':
          /// 判断是否选中一行,其它情况都不符合要求
          if (this.table.multipleSelection.length === 1) {
            this.table.editData = this.table.multipleSelection[0]
            /// 显示编辑对话框
            this.table.editDialogVisible = true
          } else {
            this.$confirm('此操作只能选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('edit')
          break
        case 'get':
          /// 获取下一层信息
          if (this.table.multipleSelection.length === 1) {
            this.shareData.tableId = this.table.multipleSelection[0].id
          } else {
            this.$message('请选择一行!')
            return
          }
          fetch(this.table.applicationName + '/' + this.table.controller + '/getLazyPermissionById', {id: this.shareData.tableId}).then(res => {
            if (res.status === 200) {
              this.$message(res.message)
              this.table2.tableData = res.data.rows
              this.table2.total(res.data.total)
            } else {
              this.$message(res.message + res.status)
            }
          })
          break
        default:
          alert('其它操作')
      }
    },
    handleCancel (type = '') {
      switch (type) {
        case 'add':
          this.table.addDialogVisible = false
          break
        case 'edit':
          this.table.editDialogVisible = false
          break
        default:
          alert('此对话框类型:+ type +不存,请查看代码')
          break
      }
    },
    handleClick2 (row = {}, type = '') {
      switch (type) {
        case 'add':
          // 显示添加数据对话框
          this.table2.addDialogVisible = true
          // 如查要对数据进行处理,在此进行,如:datetime类型
          /// 数据处理完后,赋值操作
          this.table2.addData = row
          // alert('add')
          break
        case 'delete':
          // 一行或多行删除操作
          if (this.table2.multipleSelection.length > 0) {
            // 此处生成写法是默认数据库表中字段id为唯一key值,name这一行记录名称(方便知道删除的是神马!))
            let ids = ''
            let names = ''
            this.table2.multipleSelection.forEach((selection) => {
              ids = ids + selection.id + ','
              names = names + selection.name + ','
            })
            this.$confirm(names + '确定要删除, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.delete(this.table.applicationName + '/' + this.table.controller + '/deleteBatch', {params: {ids: ids.slice(0, ids.length - 1)}})
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          } else {
            /// 不符合条件
            this.$confirm('此操作需要至少选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('删除')
          break
        case 'edit':
          /// 判断是否选中一行,其它情况都不符合要求
          if (this.table2.multipleSelection.length === 1) {
            this.table2.editData = this.table2.multipleSelection[0]
            /// 显示编辑对话框
            this.table2.editDialogVisible = true
          } else {
            this.$confirm('此操作只能选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('edit')
          break
        case 'get':
          /// 获取下一层信息
          if (this.table2.multipleSelection.length === 1) {
            this.shareData.table2Id = this.table2.multipleSelection[0].id
          } else {
            this.$message('请选择一行!')
            return
          }
          fetch(this.table.applicationName + '/' + this.table.controller + '/getLazyPermissionById', {id: this.shareData.table2Id}).then(res => {
            if (res.status === 200) {
              this.$message(res.message)
              this.table3.tableData = res.data.rows
              this.table3.total(res.data.total)
            } else {
              this.$message(res.message + res.status)
            }
          })
          break
        default:
          alert('其它操作')
      }
    },
    handleCancel2 (type = '') {
      switch (type) {
        case 'add':
          this.table2.addDialogVisible = false
          break
        case 'edit':
          this.table2.editDialogVisible = false
          break
        default:
          alert('此对话框类型:+ type +不存,请查看代码')
          break
      }
    },
    handleClick3 (row = {}, type = '') {
      switch (type) {
        case 'add':
          // 显示添加数据对话框
          this.table3.addDialogVisible = true
          // 如查要对数据进行处理,在此进行,如:datetime类型
          /// 数据处理完后,赋值操作
          this.table3.addData = row
          // alert('add')
          break
        case 'delete':
          // 一行或多行删除操作
          if (this.table3.multipleSelection.length > 0) {
            // 此处生成写法是默认数据库表中字段id为唯一key值,name这一行记录名称(方便知道删除的是神马!))
            let ids = ''
            let names = ''
            this.table3.multipleSelection.forEach((selection) => {
              ids = ids + selection.id + ','
              names = names + selection.name + ','
            })
            this.$confirm(names + '确定要删除, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.delete(this.table.applicationName + '/' + this.table.controller + '/deleteBatch', {params: {ids: ids.slice(0, ids.length - 1)}})
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          } else {
            /// 不符合条件
            this.$confirm('此操作需要至少选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('删除')
          break
        case 'edit':
          /// 判断是否选中一行,其它情况都不符合要求
          if (this.table3.multipleSelection.length === 1) {
            this.table3.editData = this.table3.multipleSelection[0]
            /// 显示编辑对话框
            this.table3.editDialogVisible = true
          } else {
            this.$confirm('此操作只能选中一行, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '取消操作!'
              })
            })
          }
          // alert('edit')
          break
        default:
          alert('其它操作')
      }
    },
    handleCancel3 (type = '') {
      switch (type) {
        case 'add':
          this.table3.addDialogVisible = false
          break
        case 'edit':
          this.table3.editDialogVisible = false
          break
        default:
          alert('此对话框类型:+ type +不存,请查看代码')
          break
      }
    },
    indexMethod (index) {
      return index + 1 + (this.table.page - 1) * this.table.limit
    },
    tableSelection (val) {
      this.table.multipleSelection = val
    },
    tableSelection2 (val) {
      this.table2.multipleSelection = val
    },
    tableSelection3 (val) {
      this.table3.multipleSelection = val
    },
    fetch (page = {
      page: 1,
      limit: this.table.limit
    }) {
      Object.assign(page, this.cacheSearchData)
      fetch(this.table.applicationName + '/' + this.table.controller + '/page', page).then((res) => {
        if (res.status === 200) {
          this.table.tableData = res.data.rows
          this.table.total = res.data.total
          this.table.page = page.page
          this.table.limit = page.limit
        } else {
          this.$message.error(res.message)
        }
      })
    },
    delete (url, params) {
      del(url, params).then((res) => {
        this.$message.success('删除成功!')
        /// 刷新页面
        this.fetch()
      })
    },
    getColumns () {
      var temp = [{'columnName': 'name', 'dataType': 'varchar'}, {'columnName': 'type', 'dataType': 'int'}]
      this.table.applicationName = 'upms'
      this.table2.applicationName = 'upms'
      this.table.controller = 'permission'
      this.table2.controller = 'permission'
      temp.forEach(item => {
        var obj = {}
        obj.prop = item.columnName
        obj.label = item.columnName
        this.table.columns.push(obj)
        this.table2.columns.push(obj)
        this.table3.columns.push(obj)
      })
    },
    getSearchFormData (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 缓存模糊查询条件
      this.table.cacheSearchData = formData
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// searchForm做整体校验,通过提交
      refs['searchForm'].validate((valid) => {
        if (valid) {
          /// 提交
          let page = {
            limit: this.limit,
            page: this.page
          }
          /// 将formData对象赋给page对象
          Object.assign(page, formData)
          /// 模糊查询提交
          this.fetch(page)
        }
      })
    },
    getAddFormData (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// addForm做整体校验,通过提交
      refs['addForm'].validate((valid) => {
        if (valid) {
          let addData = {
            type: 1,
            level: 1
          }
          /// 将formData对象赋给page对象
          Object.assign(formData, addData)
          debugger
          /// 提交
          post(this.table.applicationName + '/' + this.table.controller + '/add', formData).then((res) => {
            if (res.status === 200) {
              this.$message.success('添加成功!')
              this.table.addDialogVisible = false
              refs['addForm'].resetFields()
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    },
    getEditFormData (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// editForm提交
      refs['editForm'].validate((valid) => {
        if (valid) {
          put(this.table.applicationName + '/' + this.table.controller + '/update', formData).then((res) => {
            if (res.status === 200) {
              const h = this.$createElement
              this.$message({
                message: h('p', null, [
                  h('i', { style: 'color: teal' }, '更新成功!')
                ])
              })
              this.table.editDialogVisible = false
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    },
    getSearchFormData2 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 缓存模糊查询条件
      this.table.cacheSearchData = formData
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// searchForm做整体校验,通过提交
      refs['searchForm'].validate((valid) => {
        if (valid) {
          /// 提交
          let page = {
            limit: this.limit,
            page: this.page
          }
          /// 将formData对象赋给page对象
          Object.assign(page, formData)
          /// 模糊查询提交
          this.fetch(page)
        }
      })
    },
    getAddFormData2 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        this.$message('无提交数据!')
        return
      }
      if (this.shareData.tableId === '') {
        this.$message('请先选中一行父级菜单.再点获取后再点添加!')
        return
      }
      /// addForm做整体校验,通过提交
      refs['add2Form'].validate((valid) => {
        if (valid) {
          let addData = {
            type: 1,
            level: 2,
            pid: this.shareData.tableId
          }
          /// 将formData对象赋给page对象
          Object.assign(formData, addData)
          /// 提交
          post(this.table.applicationName + '/' + this.table.controller + '/add', formData).then((res) => {
            if (res.status === 200) {
              this.$message.success('添加成功!')
              this.table2.addDialogVisible = false
              refs['add2Form'].resetFields()
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    },
    getEditFormData2 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// editForm提交
      refs['editForm'].validate((valid) => {
        if (valid) {
          put(this.table.applicationName + '/' + this.table.controller + '/update', formData).then((res) => {
            if (res.status === 200) {
              const h = this.$createElement
              this.$message({
                message: h('p', null, [
                  h('i', { style: 'color: teal' }, '更新成功!')
                ])
              })
              this.table.editDialogVisible = false
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    },
    getSearchFormData3 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 缓存模糊查询条件
      this.table.cacheSearchData = formData
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// searchForm做整体校验,通过提交
      refs['searchForm'].validate((valid) => {
        if (valid) {
          /// 提交
          let page = {
            limit: this.limit,
            page: this.page
          }
          /// 将formData对象赋给page对象
          Object.assign(page, formData)
          /// 模糊查询提交
          this.fetch(page)
        }
      })
    },
    getAddFormData3 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        this.$message('无数据提交!')
        return
      }
      if (this.shareData.table2Id === '') {
        this.$message('上一级菜单id无,请先选择对应菜单,然后再添加此菜单对应权限!')
        return
      }
      /// addForm做整体校验,通过提交
      refs['add3Form'].validate((valid) => {
        if (valid) {
          let addData = {
            type: 2,
            pid: this.shareData.table2Id
          }
          /// 将formData对象赋给page对象
          Object.assign(formData, addData)
          debugger
          /// 提交
          post(this.table.applicationName + '/' + this.table.controller + '/add', formData).then((res) => {
            if (res.status === 200) {
              this.$message.success('添加成功!')
              this.table.addDialogVisible = false
              refs['addForm'].resetFields()
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    },
    getEditFormData3 (formData = {}, type, refs) {
      console.log(formData)
      console.log(type)
      /// 若formData数据为空,那么直接返回
      if (JSON.stringify(formData) === '{}') {
        return
      }
      /// editForm提交
      refs['editForm'].validate((valid) => {
        if (valid) {
          put(this.table.applicationName + '/' + this.table.controller + '/update', formData).then((res) => {
            if (res.status === 200) {
              const h = this.$createElement
              this.$message({
                message: h('p', null, [
                  h('i', { style: 'color: teal' }, '更新成功!')
                ])
              })
              this.table.editDialogVisible = false
              this.fetch()
            } else {
              this.$message.info(res.message)
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
